import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class AnimatedAnimatedContainerPage extends StatefulWidget {
  const AnimatedAnimatedContainerPage({super.key});

  @override
  State<AnimatedAnimatedContainerPage> createState() => _Animated1PageState();
}

class _Animated1PageState extends State<AnimatedAnimatedContainerPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Animated')),
      body: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  bool flag = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.add),
        onPressed: () {
          setState(() {
            flag = !flag;
          });
        },
      ),
      body: Stack(
        children: [
          ListView(
            children: [
              ListTile(title: Text('我是一个列表'))
            ],
          ),
          Positioned(
            left: 0,
            top: 0,
            bottom: 0,
            child: AnimatedContainer(
              duration: const Duration(milliseconds: 500),
              curve: Curves.easeIn,
              width: 200,
              height: double.infinity,
              color: flag ? Colors.red : Colors.blue,
              transform: flag ? Matrix4.translationValues(0,0,0) : Matrix4.translationValues(-200,0,0),
            ),
          ),
        ],
      ),

    );
  }
}
